#!/bin/sh

if [ -z $1 ]; then echo "use: $0 <file> <lines>" ;fi;
lines=$2

cat $1|cut -f1 -d, > $1.tmp
mv $1.tmp $1
fn=$1.`date +%s`
head -n $lines $1 > $fn
tail -n $(echo $(wc -l $1|awk '{ print $1; }')-$lines|bc) $1 > $1.tmp
mv $1.tmp $1

if [ ! -s $1 ]; then
    echo 'empty file'
    exit
fi
wget -nv -i $fn -nd -P ./music &
cat $fn
echo ok
